package com.yyairmarkyy.arctool.window;

import android.content.Context;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.support.v7.widget.RecyclerView;
import android.view.WindowManager;


import com.yyairmarkyy.arctool.item.ArcFadeItem;
import com.yyairmarkyy.arctool.item.ArcLevelItem;
import com.yyairmarkyy.arctool.item.AiyouArcMenuItem;
import com.yyairmarkyy.arctool.layoutmanager.CircleLayoutManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by aiyou on 2017/10/26.
 */

public  class ArcToolWindowParamsHelper {


    public static int LEVEL_ONE_TOP_RADIUS = 724;
    public static int LEVEL_TWO_TOP_RADIUS = 844;
    public static int CENTER_TOPRADIUS = 100;

    public static int TOOL_ITEM_RADIUS = 640;
    public static int GAME_ITEM_RADIUS = 686;
    public static int COLOR_ITEM_RADIUS = 832;

    public static int FADE_FRIST_RADIUS = 454;
    public static int FADE_WITDH = 10;
    public static int FADE_SECOND_RADIUS = 734 ;

    public static int MENU_TOP_RADIUS = 440;
    public static int MENU_ITEM_RADIUS = 394;

    public List<ArcLevelItem> levelItems;
    public List<ArcFadeItem> fadeItems;
    public AiyouArcMenuItem aiyouArcMenuItem;
    public CircleLayoutManager[] layoutManagers;


    public MenuOnclickLisitener menuOnclickLisitener;



    /**
     * 生成层参数
     * @param topRadius
     * @param shownums
     * @param adapters
     * @param layoutManagers
     * @return
     */
    public List<ArcLevelItem> makeLevelItem(int[] topRadius, int[] shownums, RecyclerView.Adapter[] adapters, CircleLayoutManager[] layoutManagers){
        this.layoutManagers = layoutManagers;
        levelItems = new ArrayList<>();
        for (int i = 0; i<adapters.length; i++){
            ArcLevelItem arcLevelItem = new ArcLevelItem();
            arcLevelItem.setLayoutManager(layoutManagers[i]);
            arcLevelItem.setAdapter(adapters[i]);
            int showNum = shownums[i];
            arcLevelItem.setShowNum(showNum);
            arcLevelItem.setTopRadius(topRadius[i]);
            levelItems.add(arcLevelItem);
        }

        return levelItems;
    }


    public WindowManager.LayoutParams makeWindowParams(int type){
//        WindowManager.LayoutParams.TYPE_APPLICATION
//                |WindowManager.LayoutParams.FLAG_DIM_BEHIND|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(type);
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.format = PixelFormat.RGBA_8888;
        return layoutParams;
    }

    /**
     * 生成分割线参数
     * @param fadeWidths
     * @param radiuses
     * @return
     */
    public List<ArcFadeItem> makeFadeItem(int[] fadeWidths, int[]radiuses){
        fadeItems = new ArrayList<>();
        for (int i = 0; i<fadeWidths.length; i++){
            ArcFadeItem fadeItem = new ArcFadeItem();
            fadeItem.setRadius(radiuses[i]);
            fadeItem.setFadeWith(fadeWidths[i]);
            fadeItem.setAlpha(0);
            fadeItem.setBackgroudColor(Color.WHITE);
            fadeItems.add(fadeItem);
        }
        return fadeItems;
    }


    /**
     * 生成菜单参数
     * @param menuOnclickLisitener
     * @return
     */
    public AiyouArcMenuItem makeMenuItem(Context context,MenuOnclickLisitener menuOnclickLisitener){
        this.menuOnclickLisitener = menuOnclickLisitener;
        return createMenuItem(context);
    }





    protected  AiyouArcMenuItem createMenuItem(Context context){
        //子类重写
        return null;
    }



    public List<ArcLevelItem> getLevelItems() {
        return levelItems;
    }

    public List<ArcFadeItem> getFadeItems() {
        return fadeItems;
    }

    public AiyouArcMenuItem getAiyouArcMenuItem() {
        return aiyouArcMenuItem;
    }


    public CircleLayoutManager[] getLayoutManagers() {
        return layoutManagers;
    }


    public interface MenuOnclickLisitener{
         void menuOnClick(int index);
    }

}
